﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
using System.Data.SqlClient;
using DataHelper;
using Utils;


namespace DAL
{
  public  class CourseDtlDao
    {
        public bool Insert(string tableName, SortedDictionary<string, string> sdList)
        {
            return new BuiltSQL().InsertTable(tableName, sdList);
        }


        public bool Update(string tableName, SortedDictionary<string, string> sdList)
        {
            return new BuiltSQL().UpdateTable(tableName, sdList);
        }

        public bool DeleteOneInfo(string dtlID)
        {
            return SQLHelper.ExecuteSqlWithTransaction("Delete from Admin_Train_CourseDtl Where DtlID=" + dtlID);
        }
        //获取一条记录
        public DataTable GetOneInfo(string dtlID)
        {
            return SQLHelper.ExecuteSqlGetDrToDt("Select * from Admin_Train_CourseDtl Where DtlID=" + dtlID);
        }
        //SQL
        public string GetSQL(string serWord )
        {

            StringBuilder strSQL = new StringBuilder("Select * From Admin_Train_CourseDtl   Where    1=1 ");
            if (!string.IsNullOrWhiteSpace(serWord))
                strSQL.Append(" And (EmpCode  Like '%" + serWord + "%' OR EmpName Like '%" + serWord + "%')");

            return strSQL.ToString();
        }
        //列表
        public DataTable GetLists(string serWord)
        {
            DataTable dt = SQLHelper.ExecuteSqlGetDrToDt(GetSQL(serWord));
            return dt;
        }
    }
}
